package Test11_05;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class ConnectionDemo05 {
	public static final String DBDRIVER = "com.mysql.jdbc.Driver";
	public static final String DBURL = "jdbc:mysql://localhost:3306/publicdemoprac";
	public static final String DBUSER = "root";
//	public static final String DBPASS = "root";
	public static final String DBPASS = "123456";
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement ps = null;
		try{
			Class.forName(DBDRIVER);
			conn=DriverManager.getConnection(DBURL, DBUSER, DBPASS);
			ps = conn.prepareStatement("insert into userprac(name,password,age)value(?,?,?)");
			for(int i=0;i<3;i++){
				ps.setString(1, "小明"+i);
				ps.setString(2, "6666"+i);
				ps.setInt(3,20+i);
				ps.executeUpdate();
			}
			ps.close();
			conn.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
